const { querySql , updateSql, insertSql , deleteSql } = require('../db')


function getDeptList(query) {
  const { deptName } = query
  return querySql(`select * from dept_list where deptName like '%${deptName || ''}%'`)
}

function editDept(query){
  query.updateTime = new Date()
  return updateSql( query , 'dept_list' , `where id = ${query.id}` )
}

function createDept(query,cardId){
  query.createTime = new Date() 
  query.createId = cardId
  return insertSql( query , 'dept_list' )
}

function deleteDept(query){
  return deleteSql('id',query.id,'dept_list')
}

module.exports = {
  getDeptList,
  editDept,
  createDept,
  deleteDept
} 